<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@include file="/WEB-INF/view/common/common.jsp" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Hiring-企业注册</title>
		<link rel="stylesheet" href="${ctx }/vendor/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
		<style>
			.n-right .msg-wrap {
				margin-left: 0 !important;
			}
			.topbar {
				position: absolute;
				right: 100px;
				top: 28px;
			}
			.topbar ul li{
				list-style: none;
				float: left;
				padding: 0 5px;
			}
		</style>
	</head>
	<body>
	   <h2 class="text-center">企业注册</h2>
	   <div class="topbar">
	   	  <ul>
	   	  	<li><a href="${ctx }/PositionServlet?command=listAll">招聘首页</a></li>
	   	  </ul>
	   </div>
	   <hr>
		
	   <div class="container">
	   	 <form id="companyRegisterForm" class="form-horizontal" action="${ctx }/company_register.action" method="post" data-validator-option="{timely:2}">
			  <div class="form-group">
			    <label for="code" class="col-sm-2 control-label">帐号：</label>
			    <div class="col-sm-10">
			      <input type="text" class="form-control" name="company.code" id="code" value="${company.code }">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="password" class="col-sm-2 control-label">密码：</label>
			    <div class="col-sm-10">
			      <input type="password" class="form-control" name="company.password" id="password" value="${company.password }" data-rule="required; password">
			    </div>
			  </div>
			  <!-- 
			  <div class="form-group">
			    <label for="repassword" class="col-sm-2 control-label">确认密码：</label>
			    <div class="col-sm-10">
			      <input type="password" class="form-control" id="redpassword" value="${company.password }" data-rule="required; match(password)">
			    </div>
			     -->
			  </div>
			  <div class="form-group">
			    <label for="name" class="col-sm-2 control-label">企业名称：</label>
			    <div class="col-sm-10">
			      <input type="text" class="form-control" name="company.name" id="name" value="${company.name }" data-rule="required; length(4, 20)">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="email" class="col-sm-2 control-label">企业邮箱：</label>
			    <div class="col-sm-10">
			      <input type="text" class="form-control" name="company.email" id="email" value="${company.email }" data-rule="required; email; length(~50)">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="phone" class="col-sm-2 control-label">企业电话：</label>
			    <div class="col-sm-10">
			      <input type="text" class="form-control" name="company.phone" id="phone" value="${company.phone }" data-rule="required; tel|mobile">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="linkman" class="col-sm-2 control-label">联系人：</label>
			    <div class="col-sm-10">
			      <input type="text" class="form-control" name="company.linkman" id="linkman" value="${company.linkman }" data-rule="required; usernameWidthChinese">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="numbers" class="col-sm-2 control-label">人数：</label>
			    <div class="col-sm-10">
			      <input type="text" class="form-control" name="company.numbers" id="numbers" value="${company.numbers }" data-rule="required; range(1~100000)">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="slogan" class="col-sm-2 control-label">服务宗旨：</label>
			    <div class="col-sm-10">
			      <input type="text" class="form-control" name="company.slogan" id="slogan" value="${company.slogan }" data-rule="required; length(~100)">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="address" class="col-sm-2 control-label">地址：</label>
			    <div class="col-sm-10">
			      <input type="text" class="form-control" name="company.address" id="address" value="${company.address }" data-rule="required; length(~100)">
			    </div>
			  </div>
			  <div class="form-group">
			    <div class="col-sm-offset-2 col-sm-10">
			      <button type="submit" class="btn btn-primary btn-block" id="submit">确认</button>
			    </div>
			  </div>
		   </form>	
	   </div>
	   <script src="<%=request.getContextPath()%>/vendor/jquery.min.js"></script>
	   <script src="<%=request.getContextPath()%>/vendor/layer/layer.js"></script>
	   <script src="<%=request.getContextPath()%>/vendor/nice-validate-1.1.2/jquery.validator.min.js?local=zh-CN"></script>
	   <script>
	   	  var msg = '${msg}';
	   	  if (msg) {
	   		  layer.msg(msg, {icon: 2})
	   	  }
	   	  
	   	  $('#companyRegisterForm').validator({
	   	    fields: {
	   	        code: {
	   	        	rule: 'required; length(2~10); remote(<%=request.getContextPath()%>/CompanyServlet?command=checkCode)',
	   	         	tip: '请输入2到10位长度的账号！',
	   	        	ok: '账号可用！',
	   		   		dataFilter: function(data) {
	   		   			if (data == 'true') {
	   		   				return '';	
	   		   			} 
	   		   			return '账号已存在';
	   		   	    }
	   	        }
	   	    }
	   	  });
	   </script>
	</body>
</html>